package ch01.sec08;

import java.util.ArrayList;
import java.util.Arrays;

public class ArrayListTest {
    public static void main(String[] args) {
        ArrayList<Integer> numbers = new ArrayList<Integer>();
        numbers.add(42);
        numbers.add(23);
        numbers.add(128);
        numbers.add(Integer.valueOf(42));
        numbers.add(365);
        System.out.println("numbers = " + Arrays.toString(numbers.toArray()));

        Integer numA = numbers.get(0);
        Integer numB = numbers.get(3);
        if (numA == numB) {
            System.out.printf("%d == %d%n", numA, numB);
        } else {
            System.out.printf("%d != %d%n", numA, numB);
        }

        if (numA.equals(numB)) {
            System.out.printf("%d equals %d%n", numA, numB);
        } else {
            System.out.printf("%d not equals %d%n", numA, numB);
        }

        String nameA = "Java";
        String nameB = new String("Java");
        if (nameA == nameB) {
            System.out.printf("%s == %s%n", nameA, nameB);
        } else {
            System.out.printf("%s != %s%n", nameA, nameB);
        }

        if (nameA.equals(nameB)) {
            System.out.printf("%s equals %s%n", nameA, nameB);
        } else {
            System.out.printf("%s not equals %s%n", nameA, nameB);
        }
    }
}
